<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>获取设置非行间样式 </title>
	</head>

	<body>
		<div id="div1" style="width: 200px; height: 200px; background: red;">
			<script>
				

				window.onload = function() {
					var div1 = document.getElementById('div1');

					alert(css(div1, 'width'));
					css(div ,'background', 'green');
				}

				function css() {
					if(arguments.length == 2) {
						return arguments[0].style[arguments[1]];
					} else if(arguments.length == 3) {
						arguments[0].style[arguments[1]] = arguments[2];
						//arguments[0].style.arguments[1]=arguments[2];
						//div1.style.background-green
					} else {
						alert("no");
					}
				}
				function css(obj,name,value){
					if(arguments.length==2){
						return obj.style[name];
					}else{
						obj.style[name]=value;
					}
				}
			</script>

	</body>

</html>